﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace YAMM
{
    public static class Jobs
    {
        //TODO Anwendungsordner
        public static string filename = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"jobs.xml");
        public static List<Job> jobs;

        static Jobs()
        { 
            //Deserialisierung
            if (System.IO.File.Exists(filename))
            {
                XmlSerializer ser = new XmlSerializer(typeof(List<Job>));
                StreamReader sr = new StreamReader(filename);
                jobs = (List<Job>)ser.Deserialize(sr);
                sr.Close();

            }
            else
            {
                jobs = new List<Job>();
            }
        }

        public static void Save()
        {
            //Serializierung
            XmlSerializer ser = new XmlSerializer(typeof(List<Job>));
            FileStream str = new FileStream(filename, FileMode.Create);
            ser.Serialize(str, jobs);
            str.Close();

        }

    }

    [Serializable()] 
    public class Job
    {
        public Job()
        {
        }
         
        public JobType id;
        public string guid;
        //TODO Parameter?
         
       // public System.Collections.Generic.Dictionary<string, string> param;
    }
    [Serializable()] 
    public enum JobType
    {
        Add,
        Remove
    }
}
